package lol.oxguy3.androidball;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.Display;
import android.view.WindowManager;

public class ColorBall {
	
	Bitmap bmpimage;
	int posX, posY, velX, velY, id;
	static int count = 1;
	int screenWidth;
	int screenHeight;
	Context cxt;
	
	public ColorBall(Context c, int x, int y) {
		id = count;
		count++;
		
		posX = x;
		posY = y;
		
		velX = 5;
		velY = 5;
		
		BitmapFactory.Options bmpfo = new BitmapFactory.Options();
		bmpfo.inJustDecodeBounds = true;
		
		cxt=c;
		
		WindowManager wm = (WindowManager) cxt.getSystemService(Context.WINDOW_SERVICE);
		Display disp = wm.getDefaultDisplay();
		
		screenWidth = disp.getWidth();
		screenHeight = disp.getHeight();
	}
	
	public void onMove(int x, int y, ColorBall cball) {
		

		if (posX>screenWidth) {
			posX -= velX;
			posY -= velY;
			velX = -velX;
		}
		
		if (posY>screenHeight) {
			posY -= velY;
			posX -= velX;
			velY = -velY;
		}

		if (posX<0) {
			posX -= velX;
			posY -= velY;
			velX = -velX;
		}
		
		if (posY<0) {
			posY -= velY;
			posX -= velX;
			velY = -velY;
		}
		
		posX+=velX;
		posY+=velY;
	}
	
	public int getId() {
		return id;
	}
	
	public Bitmap getBmpimage() {
		return bmpimage;
	}
	
	public int getPosX() {
		return posX;
	}
	
	public int getPosY() {
		return posY;
	}
	
	public int getVelX() {
		return velX;
	}
	
	public int getVelY() {
		return velY;
	}
	
	public void setPosX(int n) {
		posX = n;
	}
	
	public void setPosY(int n) {
		posY = n;
	}
	
	public void setVelX(int n) {
		velX = n;
	}
	
	public void setVelY(int n) {
		velY = n;
	}
}
